package cn.legend.travel.destination.main.controller;

import cn.legend.travel.common.pojo.po.SceneriesPO;
import cn.legend.travel.common.pojo.po.SceneryPO;
import cn.legend.travel.common.web.JsonResult;
import cn.legend.travel.destination.main.pojo.vo.CountInt;
import cn.legend.travel.destination.main.pojo.vo.SceneryVO;
import cn.legend.travel.destination.main.service.ISceneryService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 处理省市区相关请求的控制器
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/dict/scenery")
@Validated
@Api(tags = "2.景点 ")
public class ScedneryController {
    @Autowired
    private ISceneryService sceneryService;
    @GetMapping("/list-nearby-attractions")
    @ApiOperation("查询周围目的地景点列表")
    @ApiOperationSupport(order = 420)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "目的地，默认为北京", required = true, dataType = "String", example = "北京")
    })
    public JsonResult selectNearbyAttractions(@RequestParam String name) {
        log.info("开始处理【根据目的地名称查询周围目的地列表】的请求，参数：{}", name);
        List<SceneriesPO> searchHit = sceneryService.selectNearbyAttractions(name);
        return JsonResult.ok(searchHit);
    }
    @GetMapping("/sceneryList")
    @ApiOperation("查询景点列表")
    @ApiOperationSupport(order = 420)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "目的地，默认为北京", required = true, dataType = "String", example = "北京")
    })
    public JsonResult selectScenery(@RequestParam String name) {
        log.info("开始处理【根据目的地名称查询景点列表】的请求，参数：{}", name);
        List<SceneryPO> sceneryList = sceneryService.selectScenery(name);
        return JsonResult.ok(sceneryList);
    }
    @GetMapping("/listCount")
    @ApiOperation("统计")
    @ApiOperationSupport(order = 430)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "目的地，默认为北京", required = true, dataType = "String", example = "北京")
    })
    public JsonResult selectInt(@RequestParam String name) {
        log.info("开始处理【统计该目的地内的酒店，景点等等的数量】的请求，参数：{}", name);
        CountInt countInt = sceneryService.selectCount(name);
        return JsonResult.ok(countInt);
    }
    @GetMapping("/listByKeyword")
    @ApiOperation("根据关键词查询景点列表")
    @ApiOperationSupport(order = 440)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词", required = true, dataType = "String")
    })
    public JsonResult selectSceneryByKeyword(@RequestParam String keyword) {
        log.info("开始处理【根据关键词查询景点列表】的请求，参数：{}", keyword);
        List<SceneryVO> sceneryVOS = sceneryService.selectByKeyword(keyword);
        return JsonResult.ok(sceneryVOS);
    }
    @GetMapping("/listByLocation")
    @ApiOperation("查询周边景点列表")
    @ApiOperationSupport(order = 450)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "景点，故宫", required = true, dataType = "String", example = "故宫")
    })
    public JsonResult selectSceneryByLocation(@RequestParam String name) {
        log.info("开始处理【查询周边景点列表】的请求，参数：{}", name);
        List<SceneryVO> sceneryVOS = sceneryService.selectAttractions(name);
        return JsonResult.ok(sceneryVOS);
    }

    @GetMapping("/listById")
    @ApiOperation("查询景点详情")
    @ApiOperationSupport(order = 460)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "景点id", required = true, dataType = "Long")
    })
    public JsonResult selectSceneryById(@RequestParam Long id) {
        log.info("开始处理【查询周边景点列表】的请求，参数：{}", id);
        return JsonResult.ok();
    }

}
